Component({
  properties: {
    showPopup: {
      type: Boolean,
      value: false
    },
    product: {
      type: Object,
      value: {}
    }
  },

  data: {
    filteredParameters: [] // 过滤后的参数列表
  },
  
  observers: {
    'product': function(product) {
      if (product) {
        this.filterParameters(product);
      }
    }
  },

  methods: {
    filterParameters(product) {
      const parameters = [
        { name: '品名', value: product.name },
        { name: '类型', value: product.winetype },
        { name: '葡萄品种', value: product.grapeVariety },
        { name: '酒精度', value: product.alcoholContent ? `${product.alcoholContent}%` : '' },
        { name: '颜色', value: product.color },
        { name: '级别', value: product.level },
        { name: '容量', value: product.volume ? `${product.volume}ml` : '' },
        { name: '产地', value: product.origin }
      ];

      // 过滤掉值为空或 None 的参数
      const filteredParameters = parameters.filter(param => param.value && param.value !== 'null');

      this.setData({ filteredParameters });
    },

    handleClosePopup() {
      this.triggerEvent('closePopup');
    }
  }
});
